import 'package:flutter/material.dart';

import 'numberContainer.dart';

class MyAnimationApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '动画',
      home: Scaffold(
        appBar: null,
        backgroundColor: Colors.black,
        body: Center(
          child: LegoLogo(),
        ),
      ),
    );
  }
}

class LegoLogo extends StatefulWidget {
  @override
  _LegoLogoState createState() => _LegoLogoState();
}

class _LegoLogoState extends State<LegoLogo>
    with SingleTickerProviderStateMixin {
  late AnimationController _animationController;
  late Animation<Color?> _animation;

  @override
  void initState() {
    super.initState();

    _animationController = AnimationController(
      duration: const Duration(milliseconds: 800),
      vsync: this,
    );

    _animation = ColorTween(
      begin: Color.fromARGB(255, 255, 255, 255),
      end: Color.fromARGB(255, 74, 73, 73),
    ).animate(_animationController);

    _animationController.repeat(reverse: true);
  }

  @override
  void dispose() {
    print("dispose now");
    _animationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return NumberContainer(2, _animation, _animationController);
  }
}
